namespace CloudNinja.Metering.Providers.Configuration.IISLog
{
    using System.Configuration;

    using CloudNinja.Metering.Common.Configuration;

    public class IISLogMeteringProviderSettings : ConfigurationElement
    {
        [ConfigurationProperty("IISLogsRepositoryConnStr", IsRequired = true, DefaultValue = "Your connection string here")]
        public string IISLogsRepositoryConnStr
        {
            get
            {
                var currentValue = (string)this["IISLogsRepositoryConnStr"];

                return this.GetCurrentValueOrDefault(currentValue);
            }

            set
            {
                this["IISLogsRepositoryConnStr"] = value;
            }
        }

        [ConfigurationProperty("IISLogsParserBookmarkRepository", IsRequired = true, DefaultValue = "Your state repository connection string here")]
        public string IISLogsParserBookmarkRepository
        {
            get
            {
                var currentValue = (string)this["IISLogsParserBookmarkRepository"];

                return this.GetCurrentValueOrDefault(currentValue);
            }

            set
            {
                this["IISLogsParserBookmarkRepository"] = value;
            }
        }
        
        [ConfigurationProperty("TenantIdentifierLocation", IsRequired = true, DefaultValue = "hostheader")]
        [RegexStringValidator("hostheader|uri-stem|uri-query")]
        public string TenantIdentifierLocation
        {
            get
            {
                return (string)this["TenantIdentifierLocation"];
            }

            set
            {
                this["TenantIdentifierLocation"] = value;
            }
        }

        [ConfigurationProperty("TenantIdentifierPattern", IsRequired = true, DefaultValue = ".*")]
        public string TenantIdentifierPattern
        {
            get
            {
                return (string)this["TenantIdentifierPattern"];
            }

            set
            {
                this["TenantIdentifierPattern"] = value;
            }
        }
    }
}